#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <LittleFS.h>
// #include "FS.h"
#include "common.h"

#include "log.h"

// const char *ssid     = "4G-UFI-4274"; //账号
// const char *password = "Aa123456";   //密码
// const char *ssid     = "LN-WIFI-2F1";
// const char *password = "Kin123456";
const char *ssid     = "CMCC-bygya818";
const char *password = "bygya818";

const char *CFG_FILE_NM = "config.ini";

SSID_T g_wlan_info[5];

// put function declarations here:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(74880);
  File cfg_file;
  if (LittleFS.exists(CFG_FILE_NM)) {
    cfg_file = LittleFS.open(CFG_FILE_NM, "a");
  }
  else {
    cfg_file = LittleFS.open(CFG_FILE_NM, "w");
  }
  
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(5000);
    Serial.print(".");
  }

  Serial.println("Setup finished!");
}

void loop() {
  // put your main code here, to run repeatedly:
  static int cnt = 0;
  cnt++;

  char log_info[100] = {0};
  sprintf(log_info, "This is the %d message.", cnt);
  Serial.println(log_info);
  LOG(LOG_WARN, log_info);

  delay(100);
}

